<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>directive自定义指令</title>
  </head>

  <body>
    <div id="app">
      <h2 v-text='msg'></h2>
      <h2 v-upper-text='msg'></h2>
      <h2 v-lower-case="msg"></h2>
    </div>
  </body>
  <script src="../js/vue.js"></script>
  <script>
    /* 
    需求：自定义两个指令
     1.功能类似于v-text,但是转换为全大写:v-uppper-text
     2.功能类似于v-text,但是转换为全小写:v-lower-text
    */
    //1.全局的自定义指令
    Vue.directive('upper-text', function (el, binding) { //el是真实的DOM，binding是传过来的数值
      el.innerText = binding.value.toUpperCase();
    })
    new Vue({
      el: "#app",
      data() {
        return {
          msg: "helloWorld",
        }
      },
      directives: {
        'lower-case': function (el, binding) {
          el.innerText = binding.value.toLowerCase()
        }
      }
    })
  </script>

</html>